home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _61A9EFF1C1D040A4A10F2A8945E75148 < prev    next >
Text File  |  2005-03-02  |  2KB  |  73 lines

  1. //pixel shader to sample texture and environment map and mixes with material color
  2. //combines a fixed bump image with a procedurally generated one for tiny ripples
  3. //has projective reflections
  4. //Luke Lenhart
  5. //(C)2004-2005 Digipen Institute of Technology
  6.  
  7. //time since whenever
  8. float time;
  9.  
  10. //magnitude of ripples (recommend from 0.75f to 1.5f)
  11. float ripMag;
  12.  
  13. //base texture
  14. //sampler sampTex;
  15.  
  16. //cube texture
  17. sampler sampCube;
  18.  
  19. //projective reflection texture
  20. sampler sampProjRefl;
  21.  
  22. //
  23. struct PS_INPUT
  24. {
  25.     //float2 Tex0 : TEXCOORD0;
  26.     float3 EnvTex : TEXCOORD1;
  27.     float4 Clr : COLOR;
  28.     float3 Pos : TEXCOORD2;
  29.     float4 ProjTxt : TEXCOORD3;
  30.     float CamDist : TEXCOORD4;
  31.     float CamDist2 : TEXCOORD5;
  32.     //float FogClr : TEXCOORD6;
  33. };
  34.  
  35. float4 PShader(PS_INPUT In) : COLOR
  36. {
  37.     //calc wave offset 0 and 1
  38.     float3 tmpW0sin, tmpW0cos;
  39.     sincos(2*time+In.Pos,tmpW0sin,tmpW0cos);
  40.  
  41.     float3 normWave=sin(tmpW0sin+(In.Pos.y)/In.CamDist);
  42.  
  43.     //combine waves    to use as normal modifier
  44.     float3 normOff;
  45.     normOff.x=100*(sin(In.CamDist*0.1f)/In.CamDist)*(tmpW0sin.y);
  46.     normOff.y=100*(cos(In.CamDist*0.1f)/In.CamDist)*(tmpW0sin.x);
  47.     normOff.z=1.0f;
  48.     normOff*=ripMag*0.05f;
  49.         
  50.     //calc proj text warp
  51.     float4 projTxtWaved=In.ProjTxt;
  52.     float2 projMod=sin(time*8.5f+In.CamDist*0.23f)*float2(0.5f,0.4f)*(10.0f/In.CamDist2);
  53.     projTxtWaved.xy=In.ProjTxt.xy+projMod;
  54.     
  55.     //combine env map, color map sample, and projective texture sample
  56.     //float4 clrPlain=tex2D(sampTex,time+In.Tex0);
  57.     float4 clrEnv=texCUBE(sampCube,normOff+In.EnvTex);
  58.     float4 clrProjRefl=tex2Dproj(sampProjRefl,projTxtWaved);
  59.     
  60.     float4 clr=float4(0.06f,0.135f,0.3f,0) + 0.85f*clrEnv + 0.6f*clrProjRefl;
  61.     
  62.     //apply vert color
  63.     clr*=In.Clr;
  64.     
  65.     //add fog color
  66.     //clr.xyz+=In.FogClr;
  67.     
  68.     //set alpha from vert color
  69.     clr.a=In.Clr.a;
  70.     
  71.     return clr;
  72. }
  73.